<template>
  <div class="app-container drag-container" id="drag-container">
    <el-row :gutter="0">
      <el-col :xs="24" :sm="6" :md="5" :lg="4" class="drag-area" id="drag-area">
        <div style="text-align: center; color: #0fa8e7">数据选择</div>
        <el-input
          style="width: 80%"
          placeholder="输入关键字"
          prefix-icon="el-icon-search"
          v-model="filterText"
        >
        </el-input>

        <el-tree
          class="filter-tree"
          :data="data"
          :props="defaultProps"
          @node-click="handleNodeClick"
          :filter-node-method="filterNode"
          ref="tree"
        ></el-tree>
        <div class="drag-tip" id="drag-tip"></div>
      </el-col>

      <el-col :xs="24" :sm="18" :md="18.7" :lg="20" id="drag-content">
        <el-form
          :model="queryParams"
          ref="queryForm"
          :inline="true"
          v-show="showSearch"
          label-width="68px"
        >
          <el-form-item label="试卷模板名称" prop="name">
            <el-input
              v-model="queryParams.name"
              placeholder="请输入试卷模板名称"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="创建时间" prop="createTime">
            <el-date-picker
              clearable
              size="small"
              v-model="queryParams.createTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择创建时间"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="创建人" prop="createBy">
            <el-input
              v-model="queryParams.createBy"
              placeholder="请输入创建人"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="修改时间" prop="updateTime">
            <el-date-picker
              clearable
              size="small"
              v-model="queryParams.updateTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择修改时间"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="修改人" prop="updateBy">
            <el-input
              v-model="queryParams.updateBy"
              placeholder="请输入修改人"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="handleQuery"
              >搜索</el-button
            >
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
              >重置</el-button
            >
          </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd"
              v-hasPermi="['paper:template:add']"
              >新增</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="success"
              plain
              icon="el-icon-edit"
              size="mini"
              :disabled="single"
              @click="handleUpdate"
              v-hasPermi="['paper:template:edit']"
              >修改</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              plain
              icon="el-icon-delete"
              size="mini"
              :disabled="multiple"
              @click="handleDelete"
              v-hasPermi="['paper:template:remove']"
              >删除</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="warning"
              plain
              icon="el-icon-download"
              size="mini"
              :loading="exportLoading"
              @click="handleExport"
              v-hasPermi="['paper:template:export']"
              >导出</el-button
            >
          </el-col>
          <right-toolbar
            :showSearch.sync="showSearch"
            @queryTable="getList"
          ></right-toolbar>
        </el-row>

        <el-table
          v-loading="loading"
          :data="templateList"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="试卷模板名称" align="center" prop="name" />
          <el-table-column label="试卷总分" align="center" prop="score" />
          <el-table-column label="考试时间" align="center" prop="time" />
          <el-table-column
            label="创建时间"
            align="center"
            prop="createTime"
            width="180"
          >
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d}") }}</span>
            </template>
          </el-table-column>
          <el-table-column label="创建人" align="center" prop="createBy" />
          <el-table-column
            label="修改时间"
            align="center"
            prop="updateTime"
            width="180"
          >
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.updateTime, "{y}-{m}-{d}") }}</span>
            </template>
          </el-table-column>
          <el-table-column label="修改人" align="center" prop="updateBy" />
          <el-table-column
            label="操作"
            align="center"
            class-name="small-padding fixed-width"
          >
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-view"
                @click="handleUpdate(scope.row, false)"
                >预览</el-button
              >

              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row, true)"
                v-hasPermi="['paper:template:edit']"
                >修改</el-button
              >

              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                v-hasPermi="['paper:template:remove']"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>

    <!-- 添加或修改试卷模板对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="70%" append-to-body>
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="120px"
        label-position="left"
      >
        <div class="dialog-header">
          <el-row :gutter="15"
            ><div>
              <el-col :span="12">
                <el-form-item label="试卷模板名称" prop="name">
                  <el-input
                    v-model="form.name"
                    placeholder="请输入试卷模板名称"
                    :disabled="!modify"
                  />
                </el-form-item>
              </el-col>
            </div>
            <div>
              <el-col :span="12">
                <el-form-item label="关联课程" prop="courseId">
                  <el-select
                    v-model="form.courseId"
                    placeholder="请选择课程"
                    clearable
                    filterable
                    size="small"
                    style="width: 100%"
                  >
                    <el-option
                      v-for="item in courseList"
                      :key="item.id"
                      :label="item.courseName"
                      :value="item.id"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
              <!-- <el-col :span="12">
                <el-form-item label="试卷总分" prop="score">
                  {{ TotalScore }}
                </el-form-item>
              </el-col> -->
            </div>
          </el-row>

          <el-row :gutter="15">
            <div>
              <el-col :span="12">
                <el-form-item label="考试时长" prop="time">
                  <el-input
                    v-model.number="form.time"
                    placeholder="请输入考试时长（单位：分钟）"
                    :disabled="!modify"
                  />
                </el-form-item>
              </el-col>
            </div>
            <el-col :span="12">
              <el-button type="primary" @click="addQuestion" :disabled="!modify"
                >添加大题</el-button
              >
            </el-col>
          </el-row>
        </div>
        <div v-for="(item, index) in form.structureList" :key="index">
          <el-row :gutter="15">
            <el-col :span="3">
              <el-button type="primary">第{{ index + 1 }}题</el-button>
            </el-col>

            <el-col :span="1.5">
              <el-button
                type="success"
                plain
                icon="el-icon-plus"
                size="mini"
                :disabled="!modify"
                @click="openQuestionDialog(index)"
                >选择题型模板</el-button
              >
            </el-col>

            <el-col :span="1.5">
              <el-button
                type="danger"
                plain
                icon="el-icon-delete"
                size="mini"
                :disabled="!modify"
                @click="deleteOneQuestion(index)"
                style="vertical-align: bottom"
                >删除</el-button
              >
            </el-col>

            <el-col :span="1">
              <i
                class="el-icon-arrow-down"
                v-show="qTindex[index]"
                @click="fold(index)"
                style="font-size: 20px; height: 30px; line-height: 30px"
              ></i>
              <i
                class="el-icon-arrow-up"
                v-show="!qTindex[index]"
                @click="fold(index)"
                style="font-size: 20px; height: 30px; line-height: 30px"
              ></i>
            </el-col>

            <el-col :span="12">
              <span v-if="!qTindex[index]">
                大题名称：
                {{
                  form.structureList[index].name
                    ? "" + form.structureList[index].name
                    : "无"
                }}
                大题中小题数量: {{ form.structureList[index].count }} 大题总分：
                {{ form.structureList[index].score }}
              </span>
              <span v-else> </span>
            </el-col>
          </el-row>

          <div v-show="qTindex[index] === true">
            <el-row :gutter="15">
              <el-col :span="12">
                <el-form-item
                  label="题型名称"
                  :prop="`structureList[${index}].type`"
                  :rules="{
                    required: true,
                    message: '请选择题型名称',
                    trigger: 'change',
                  }"
                >
                  <el-input
                    v-model="form.structureList[index].type"
                    style="width: 0px; display: none"
                  />
                  <span v-if="form.structureList[index].type">
                    {{ form.structureList[index].type }}
                  </span>
                  <span v-else> 请选择题型模板 </span>
                </el-form-item>
              </el-col>

              <el-col :span="12">
                <el-form-item
                  label="大题名称"
                  :prop="`structureList[${index}].name`"
                  :rules="{
                    required: true,
                    message: '请输入大题名称',
                    trigger: 'blur',
                  }"
                >
                  <el-input
                    v-model="form.structureList[index].name"
                    placeholder="请输入大题名称"
                    :disabled="!modify"
                  />
                </el-form-item>
              </el-col>
            </el-row>

            <el-row :gutter="15">
              <el-col :span="12">
                <el-form-item
                  label="大题中小题数量"
                  :prop="`structureList[${index}].count`"
                  :rules="{
                    required: true,
                    message: '请输入大题中小题数量',
                    trigger: 'blur',
                  }"
                >
                  <el-input
                    v-model.number="form.structureList[index].count"
                    placeholder="请输入大题中小题数量"
                    @change="changeScore(index)"
                    :disabled="!modify"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="模板名称">
                  <span v-if="form.structureList[index].template">
                    {{ form.structureList[index].template.name }}
                  </span>
                  <span v-else> </span>
                </el-form-item>
              </el-col>
              <!-- <el-col :span="12" v-show="false">
                <el-form-item label="大题总分" prop="questionScore">
                  <span v-if="form.structureList[index].score">
                    {{ form.structureList[index].score }}
                  </span>
                  <span v-else> </span>
                </el-form-item>
              </el-col> -->
            </el-row>

            <el-row :gutter="15" v-show="false">
              <!-- <el-col :span="12">
                <el-form-item label="选项数量">
                  <span v-if="qObjArray[index] != null">
                    {{ qObjArray[index].count }}
                  </span>
                  <span v-else> </span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="小题分值" prop="questionScore">
                  <span v-if="qObjArray[index] != null">
                    {{ qObjArray[index].questionScore }}
                  </span>
                  <span v-else> </span>
                </el-form-item>
              </el-col> -->
            </el-row>
          </div>

          <div v-show="qTindex[index] === false" style="height: 20px"></div>
        </div>
      </el-form>

      <el-dialog
        title="请选择大题"
        :visible.sync="questiondialog"
        width="70%"
        append-to-body
      >
        <div class="app-container">
          <el-table
            v-loading="qloading"
            :data="qtemplateList"
            @row-click="rowclick($event)"
            highlight-current-row
          >
            <el-table-column type="index" width="55" align="center">
            </el-table-column>
            <el-table-column label="模板名称" align="center" prop="name" />
            <el-table-column label="题型名称" align="center" prop="type" />
            <el-table-column label="题型数量" align="center" prop="count" />
            <el-table-column
              label="小题分值"
              align="center"
              prop="questionScore"
            />
          </el-table>

          <pagination
            v-show="qtotal > 0"
            :total="qtotal"
            :page.sync="qqueryParams.pageNum"
            :limit.sync="qqueryParams.pageSize"
            @pagination="qgetList"
          />
        </div>

        <div slot="footer" class="dialog-footer">
          <el-button @click="closeQuestionDialogF">取 消</el-button>
          <el-button type="primary" @click="closeQuestionDialogT"
            >确 定</el-button
          >
        </div>
      </el-dialog>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm" v-show="modify"
          >确 定</el-button
        >
        <el-button @click="cancel" v-show="modify">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listTemplate,
  getTemplate,
  delTemplate,
  addTemplate,
  updateTemplate,
  exportTemplate,
} from "@/api/paper/template";

import { listTemplate as qlistTemplate } from "@/api/topic/template";
import { listCourse } from "@/api/org/course";
export default {
  name: "Template",
  data() {
    return {
      //选择大题的弹出框
      questiondialog: false,
      // 遮罩层
      // *******************************
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件*********************************
      showSearch: true,
      // 总条数
      total: 0,
      // 试卷模板表格数据
      templateList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      //true代表当前是修改操作，试卷模板可编辑，false代表当前是预览操作，试卷模板不可以编辑
      modify: true,
      //课程选择
      courseList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        createTime: null,
        createBy: null,
        updateTime: null,
        updateBy: null,
      },

      // 大题参数
      question: {
        paperTemplateId: "", //试卷模板id
        questionTemplateId: "", //题型模板id
        name: "", //大题名称
        score: 0.0, //大题总分
        type: "", //题型名称
        beanName: "", //题型编码
        count: null, //大题中小题数量
        ordered: "", //排序
      },
      // 表单参数
      form: {
        id: null,
        createTime: null,
        createBy: null,
        updateTime: null,
        updateBy: null,
        courseId: null,
        name: "", //试卷模板名称
        score: 0.0, //试卷总分
        time: "", //考试时间
        structureList: [], //大题信息数组
      },
      // 表单校验
      rules: {
        name: [
          { required: true, message: "请输入试卷模板名称", trigger: "blur" },
        ],
        time: [{ required: true, message: "请输入考试时长", trigger: "blur" }],
        courseId: [
          { required: true, message: "请选择关联课程", trigger: "blur" },
        ],
      },

      // 下面是选择大题弹框的相关信息
      // 遮罩层
      // *****************************$$$$$$$$$$$$$$$$$$$$$$$$$
      qloading: true,

      // 选中数组$$$$$$$$$$$$$$$$$$$$$$$$
      qObj: {},
      qScoreArray: [10, 20, 30],
      //当前新增试卷中各个大题的详细信息
      qObjArray: [],
      // 当前大题所在数组中的索引
      qindex: 0,
      // 非单个禁用$$$$$$$$$$$$$$$$$$$$$$$$
      qsingle: false,
      // 非多个禁用$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      qmultiple: true,

      // 总条数********************************$$$$$$$$$$$$$$$$$$$$$$$
      qtotal: 0,
      // 题型模板表格数据*********************************$$$$$$$$$$$$$$$$$$$$$$$$$
      qtemplateList: [],
      //题型
      qtypeOptions: [],

      // 查询参数*******************************$$$$$$$$$$$$$$$$$
      qqueryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        beanName: null,
        type: null,
        count: null,
        questionScore: null,
        multipleFlag: null,
        multipleFraction: null,
      },
      // 判断大题是否折叠显示  true 展开， false折叠
      qTindex: [],

      filterText: "",
      data: [
        {
          label: "信息工程学院",
          children: [
            {
              label: "数据结构",
            },
            {
              label: "算法",
            },
            {
              label: "操作系统",
            },
          ],
        },
        {
          label: "法学院",
          children: [
            {
              label: "数据结构",
            },
            {
              label: "算法",
            },
            {
              label: "操作系统",
            },
          ],
        },
        {
          label: "土木学院",
          children: [
            {
              label: "数据结构",
            },
            {
              label: "算法",
            },
            {
              label: "操作系统",
            },
          ],
        },
        {
          label: "物理学院",
          children: [
            {
              label: "数据结构",
            },
            {
              label: "算法",
            },
            {
              label: "操作系统",
            },
          ],
        },
        {
          label: "人文学院",
          children: [
            {
              label: "数据结构",
            },
            {
              label: "算法",
            },
            {
              label: "操作系统",
            },
          ],
        },
      ],
      defaultProps: {
        children: "children",
        label: "label",
      },
    };
  },
  watch: {
    filterText(val) {
      this.$refs.tree.filter(val);
    },
  },
  created() {
    this.getList();
    this.getlistcourse();
    // 下面是选择大题弹框的相关信息
    this.qgetList();
    this.getDicts("question_type").then((response) => {
      this.qtypeOptions = response.data;
      console.log("qtypeoptinons:", this.qtypeOptions);
    });
  },

  methods: {
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    handleNodeClick(data) {
      console.log(data);
    },
    // 获取课程
    getlistcourse() {
      listCourse().then((response) => {
        this.courseList = response.rows;
        console.log(this.courseList);
      });
    },
    // 深拷贝
    deepclone(obj) {
      // 如果当前要深拷贝的对象不是对象类型，或者为空的对象类型则返回原值
      if (typeof obj !== "object" || obj == null) {
        return obj;
      }
      // 判断obj对象的类型，然后对结果进行初始化
      let result;
      if (obj instanceof Array) {
        result = [];
      } else {
        result = {};
      }

      for (let key in obj) {
        // 当前值是对象自身的属性
        if (obj.hasOwnProperty(key)) {
          result[key] = this.deepclone(obj[key]);
        }
      }

      return result;
    },
    // 点击添加大题按钮，添加大题
    addQuestion() {
      let newQuestion = this.deepclone(this.question);
      this.form.structureList.push(newQuestion);
      this.qTindex.push(true);
      console.log("addQuestion");
    },
    // 点击删除某一个大题
    deleteOneQuestion(index) {
      this.form.structureList.splice(index, 1);
      this.qTindex.splice(index, 1);
      this.qObjArray.splice(index, 1);
    },
    //点击后折叠大题
    fold(index) {
      console.log(index);

      let flag = this.qTindex[index];
      this.qTindex[index] = !flag;
      let newArray = this.deepclone(this.qTindex);
      this.qTindex = newArray;

      console.log(this.qTindex);
      console.log("this.qTindex:", this.qTindex[index]);
    },
    /** 查询试卷模板列表 */
    // *****************************************
    getList() {
      this.loading = true;
      listTemplate(this.queryParams).then((response) => {
        this.templateList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        createTime: null,
        createBy: null,
        updateTime: null,
        updateBy: null,
        courseId: null,
        name: "",
        score: 0.0,
        time: "",
        structureList: [], //大题信息数组
      };

      this.qTindex = [];
      this.qObjArray = [];

      let newQuestion = this.deepclone(this.question);
      this.form.structureList.push(newQuestion);
      this.qTindex.push(true);

      console.log(this.form.structureList);

      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    // ***************************************************
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    // *****************************************
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加试卷模板";
    },
    /** 修改按钮操作 */
    handleUpdate(row, flag) {
      this.reset();
      const id = row.id || this.ids;
      getTemplate(id).then((response) => {
        this.form = response.data;
        this.modify = flag;

        console.log("form:", this.form);
        this.editQuestion(this.form.structureList);

        this.open = true;
        if (flag) {
          this.title = "修改试卷模板";
        } else {
          this.title = "预览试卷模板";
        }
      });
    },
    // 将返回的表单中大题中的详细信息赋值为qObjArray， qTindex
    editQuestion(structureL) {
      this.qObjArray = [];
      this.qTindex = [];
      const length = structureL.length;
      for (let i = 0; i < length; i++) {
        let obj = this.deepclone(structureL[i].template);
        let index = true;
        this.qObjArray.push(obj);
        this.qTindex.push(index);
      }
      console.log(this.qObjArray);
      console.log("qINDEX:", this.qTindex);
    },

    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        this.form.score = this.TotalScore;
        if (valid) {
          if (this.form.id != null) {
            console.log("修改后提交的数据： ", this.form);
            this.open = false;

            updateTemplate(this.form).then((response) => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            console.log("要提交的数据： ", this.form);
            this.open = false;

            addTemplate(this.form).then((response) => {
              this.msgSuccess("新增成功");
              // this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    // ***********************************************
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm(
        '是否确认删除试卷模板编号为"' + ids + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return delTemplate(ids);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有试卷模板数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.exportLoading = true;
          return exportTemplate(queryParams);
        })
        .then((response) => {
          this.download(response.msg);
          this.exportLoading = false;
        })
        .catch(() => {});
    },
    // 下面是选择弹框的相关方法
    // 打开内部对话框
    openQuestionDialog(index) {
      this.questiondialog = true;
      this.qindex = index;
      console.log("qindex: ", this.qindex);
      console.log("this.form.structureList: ", this.form.structureList);
    },
    /** 查询题型模板列表 */
    // ******************************************
    qgetList() {
      this.qloading = true;
      qlistTemplate(this.qqueryParams).then((response) => {
        this.qtemplateList = response.rows;
        console.log("qtemplateList****:", this.qtemplateList);
        this.qtotal = response.total;
        this.qloading = false;
      });
    },

    // 用户选框选中数据******************************************************$$$$$$$$$
    rowclick(e) {
      console.log("****************************");
      console.log(e);
      this.qObj = e;
    },

    // 关闭内部对话框    用户点击确定
    closeQuestionDialogT() {
      this.form.structureList[this.qindex].type = this.qObj.type;
      this.form.structureList[this.qindex].beanName = this.qObj.beanName;
      this.form.structureList[this.qindex].questionTemplateId = this.qObj.id;
      // this.form.structureList[this.qindex].questionScore=this.qObj.questionScore
      this.form.structureList[this.qindex].template = {};
      this.form.structureList[this.qindex].template.name = this.qObj.name;
      console.log(this.qObj, 1111111111111);
      let obj = this.deepclone(this.qObj);
      this.qObjArray.push(obj);
      console.log("********closeQuestionDialogT**********");
      console.log("this.form.structureList: ", this.form.structureList);
      console.log("this.qObjArray: ", this.qObjArray);
      console.log("********closeQuestionDialogT**********");

      this.questiondialog = false;
    },

    // 关闭内部对话框，   用户点击取消
    closeQuestionDialogF() {
      this.questiondialog = false;
      this.qObj = {};
    },
    //当试卷中大题中小题的数量发生变化时，更新大题总分
    changeScore(index) {
      // if(this.form.structureList[index].count>0){
      //   console.log("changeScore函数中：");
      // console.log("count: ", this.form.structureList[index].count);
      // console.log("questionScore: ", this.qObjArray[index].questionScore);
      //   this.form.structureList[index].score =
      //   this.form.structureList[index].count *
      //   this.qObjArray[index].questionScore;
      // console.log("Score: ", this.form.structureList[index].score);
      // }
    },
  },
  computed: {
    //添加试卷模板中的总分，
    TotalScore() {
      let total = 0.0;
      let length = this.form.structureList.length;
      for (let i = 0; i < length; i++) {
        total += this.form.structureList[i].score;
      }
      return total;
    },
  },
};
</script>

<style lang="scss">
.zhedie {
  /* display: none; */
}
.clearfix:after {
  content: "";
  display: table;
  clear: both;
}
.el-table__body tr.current-row > td {
  //   ::v-deep
  background-color: #c0daff !important;
}
</style>
